package cn.lijiajia3515.cairo.auth.framework.security.oauth2;

import cn.lijiajia3515.cairo.auth.framework.security.oauth2.client.userinfo.OAuth2Userinfo;
import cn.lijiajia3515.cairo.auth.modules.auth.AuthType;
import cn.lijiajia3515.cairo.security.authentication.CairoAuthentication;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.springframework.security.oauth2.core.user.OAuth2User;

import java.util.Map;

@Getter
@Setter
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@SuperBuilder(toBuilder = true)
@NoArgsConstructor
public class CairoOAuth2User extends CairoAuthentication implements OAuth2User {


	/**
	 * 认证类型
	 */
	private AuthType type;

	/**
	 * oauth2 对象
	 */
	private OAuth2Userinfo oAuth2Userinfo;
	/**
	 * oauth2 attribute
	 */
	private Map<String, Object> attributes;


	@Override
	public <A> A getAttribute(String name) {
		return OAuth2User.super.getAttribute(name);
	}

	@Override
	public Map<String, Object> getAttributes() {
		return attributes;
	}

	@Override
	public String getName() {
		return getId();
	}
}
